package cate.game.fight.hero.dyn;

import cate.common.table.dynins.DynFurnitureRow;
import cate.common.table.dynins.DynHeroLevelRow;
import cate.common.table.item.hero.row.HeroBaseRow;
import cate.common.util.XT;
import cate.game.attr.FightAttr;
import cate.game.role.bag.hero.Hero;
import org.apache.commons.lang3.StringUtils;

import java.util.List;

public class DynFurnitureUtil extends DynItemUtil {

	@Override
	public void setUp(Hero hero, HeroBaseRow heroTpl, DynHeroLevelRow itemTpl) {
		if (itemTpl.furnitureCode <= 0) {
			return;
		}
		DynFurnitureRow furnitureRow = ctx.dynInsExcel().furniture.get(itemTpl.furnitureCode);
		if (furnitureRow == null) {
			return;
		}
		String attrStr = furnitureRow.getAttrStr(heroTpl.job);
		if (StringUtils.isNotBlank(attrStr)) {
			hero.exPart.addAttr(new FightAttr(attrStr));
		}
		List<Integer> skills = furnitureRow.getSkills(heroTpl.job);
		if (XT.isNotBlank(skills)) {
			hero.exPart.addSkills(skills);
		}

	}
}
